﻿using System.Configuration;
using System.Collections.Specialized;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Objects;

namespace medder
{
    public partial class RegReg : Form
    {
        User user;
        MedBaseEntities med = new MedBaseEntities();
        public static ObjectSet<User> users;


        public RegReg(User user)
        {
            this.user = user;
            users = med.Users;
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string activeCode = ConfigurationManager.AppSettings.Get("activeCode");
            string actCodeUser = textBox1.Text;
            if (activeCode.Equals(actCodeUser))
            {
                user.TypeId = (int)TypeEnum.Registrator;
                user.IsActive = true;
                med.AddToUsers(user);
                med.SaveChanges();
                this.Close();
                SuccessReg fm1 = new SuccessReg(user);
                fm1.ShowDialog();

            }
            else
            {
                Info.Text = "Введен неправильный активационный ключ";
            }

            
           

        }
    }
}
